package com.peng.utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;
import org.apache.commons.text.StringSubstitutor;
import org.junit.jupiter.api.Test;

/**
 * GenerateBeehiveDecisionSceneFieldSqlTest2
 *
 * @author lupeng10
 * @create 2024-08-22 11:33
 */
public class GenerateBeehiveDecisionSceneFieldSqlTest2 {
/*
select * from t_decision_scene where unikey in (
'wb_position_promotion',
'gj_position_promotion',
'zcm_position_promotion',
'wb_position_promotion_jz',
'gj_position_promotion_jz',
'zcm_position_promotion_jz',
'dosage_card_wb_vip_scene_key',
'dosage_card_gj_vip_scene_key',
'dosage_card_zcm_vip_scene_key',
'wb_position_promotion_vip',
'gj_position_promotion_vip',
'zcm_position_promotion_vip',
'radar_wb_vip_recommend_list',
'radar_zcm_vip_recommend_list',
'radar_gj_vip_recommend_list'
);
*/

    @Test
    public void t1() {
        String sqlTemplate = """
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId, cascade_control, cascade_field) VALUES (${id1}, 1, 'productList', '推广产品列表', 6, ${sceneId}, null, null, '2024-08-22 11:23:58', 'lupeng10', '2024-08-22 11:24:14', 'lupeng10', 0, 'null', 0);
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId, cascade_control, cascade_field) VALUES (${id2}, 1, 'productCode', '商业产品', 7, ${sceneId}, '[{"disabled":false,"label":"简历宝","value":"JIAN_LI_BAO"},{"disabled":false,"label":"优客宝","value":"UKEBAO"},{"disabled":false,"label":"超级置顶职位","value":"SUPER_INVITE_INFO"},{"disabled":false,"label":"黄金展位","value":"HUANG_JIN"},{"disabled":false,"label":"加量卡","value":"DOSAGE_CARD"},{"disabled":false,"label":"加速卡","value":"SPEED_CARD"},{"disabled":false,"label":"人才雷达","value":"RADAR"},{"disabled":false,"label":"个人超值套餐","value":"PERSON_PACKAGE"}]', null, '2024-08-22 11:23:58', 'lupeng10', '2024-08-22 11:24:14', 'lupeng10', ${id1}, 'null', 0);
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId, cascade_control, cascade_field) VALUES (${id3}, 1, 'productDescribe', '商品描述', 1, ${sceneId}, null, null, '2024-08-22 11:23:58', 'lupeng10', '2024-08-22 11:24:14', 'lupeng10', ${id1}, 'null', 0);
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId, cascade_control, cascade_field) VALUES (${id4}, 1, 'productFirstDescribe', '首推文案', 1, ${sceneId}, null, null, '2024-08-22 11:23:58', 'lupeng10', '2024-08-22 11:24:14', 'lupeng10', ${id1}, 'null', 0);
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId, cascade_control, cascade_field) VALUES (${id6}, 1, 'productIconUrl', 'icon', 1, ${sceneId}, null, null, '2024-08-22 11:23:58', 'lupeng10', '2024-08-22 11:24:14', 'lupeng10', ${id1}, 'null', 0);
                INSERT INTO t_decision_scene_field (id, scope, field_key, field_name, field_type, scene_id, options, callback_url, created_at, created_by, updated_at, updated_by, parentId, cascade_control, cascade_field) VALUES (${id7}, 1, 'productOrder', '排序', 1, ${sceneId}, null, null, '2024-08-22 11:23:58', 'lupeng10', '2024-08-22 11:24:14', 'lupeng10', ${id1}, 'null', 0);
                """;

        List<String> sceneIdList = new ArrayList<>();
        // sceneIdList.add("1646357879369809923");
        // sceneIdList.add("1646357725577269250");
        // sceneIdList.add("1646357804518273025");
        // sceneIdList.add("1736661337028751361");
        // sceneIdList.add("1736661591132262400");
        // sceneIdList.add("1736661697055219712");
        // sceneIdList.add("1739194135895650305");
        // sceneIdList.add("1739195250133483521");
        // sceneIdList.add("1739195720260448257");
        // sceneIdList.add("1745705905384652800");
        // sceneIdList.add("1745706096963674114");
        // sceneIdList.add("1745706196423213056");


        // sceneIdList.add("1698885434618200064");
        // sceneIdList.add("1698886087839117313");
        // sceneIdList.add("1698886352940105730");


        // 生产ID
        sceneIdList.add("1646357725577269250"); //58 极速版-职位管理-职位推广
        sceneIdList.add("1646357804518273025"); //赶集极速版-职位管理-职位推广
        sceneIdList.add("1646357879369809923"); //招才猫-职位管理-职位推广
        sceneIdList.add("1698885434618200064"); //兼职-58 极速版-职位管理-职位推广
        sceneIdList.add("1698886087839117313"); //兼职-赶集极速版-职位管理-职位推广
        sceneIdList.add("1698886352940105730"); //兼职-招才猫-职位管理-职位推广
        sceneIdList.add("1736661337028751361"); //加量卡-五八-会员
        sceneIdList.add("1736661591132262400"); //加量卡-赶集-会员
        sceneIdList.add("1736661697055219712"); //加量卡-招才猫-会员
        sceneIdList.add("1739194135895650305"); //58极速版-职位管理-职位推广-会员
        sceneIdList.add("1739195250133483521"); //赶集极速版-职位管理-职位推广-会员
        sceneIdList.add("1739195720260448257"); //招才猫-职位管理-职位推广-会员
        sceneIdList.add("1745705695480705025"); //人才雷达-五八-职位推广-会员
        sceneIdList.add("1745705905384652800"); //人才雷达-招才猫-职位推广-会员
        sceneIdList.add("1745706196423213056"); //人才雷达-赶集-职位推广-会员


        long startId = 1830561193627050033L;
        for (String sceneId : sceneIdList) {
            Map<String, Object> params = new HashMap<>();
            params.put("sceneId", sceneId);

            params.put("id1", startId++);
            params.put("id2", startId++);
            params.put("id3", startId++);
            params.put("id4", startId++);
            params.put("id5", startId++);
            params.put("id6", startId++);
            params.put("id7", startId++);

            System.out.println("#############start############ sceneId:" + sceneId);
            System.out.println(new StringSubstitutor(params).replace(sqlTemplate));
            System.out.println("#########################");
            System.out.println();
        }
    }


    @Test
    public void t2() {
        int cnt = 0;
        for (int i = 0; i < 10000; i++) {
            int x = ThreadLocalRandom.current().nextInt(0, 100);
            if (x <= 10) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }

}
